<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//Dtd XHTML 1.0 Transitional//EN" "http://www.w3.org/tr/xhtml1/Dtd/xhtml1-transitional.dtd">
<html>
	<head>
		<%@include file="/WEB-INF/page/include/head.jsp"%>
		<title>用户列表页</title>
	</head>
	<body >
		 <s:form action="user_searchList" namespace="/user" method="post" theme="simple" onsubmit="showCustomDiv(true,'apdiv','waitIframe',1);return true;">
			用户管理<input type="button" value="添加" onclick="toEdit(-1)"/>
		 	<div style="height: 420px; overflow: auto">
			 	<TABLE  width="100%">
			 		<%-- 数据--%>
			 		<TR>
			 			<TD >
			 				<TABLE id="dateContext" width="100%" rules="all">
			 					<TR>
			 						<TH>
			 							序号
			 						</TH>
			 						<TH>
			 							用户名
			 						</TH>
			 						<TH>
			 							性别
			 						</TH>
			 						<TH>
			 							最后登录时间
			 						</TH>
			 						<TH>
			 							最后登录Ip
			 						</TH>
			 						<TH>
			 							是否管理员
			 						</TH>
			 						<TH>
			 							删除
			 						</TH>
			 					</TR>
			 					
			 					<s:iterator var="tmpBean" value="#request.pageData.pageItems" status="status">
			 					<TR name="listTR" ondblclick="toEdit(<s:property value='#tmpBean.id'/>)">
			 						<TD  >
			 							<s:property value="#status.getIndex()+1"/>
			 						</TD>
			 						<TD>
			 							<s:property value="#tmpBean.realName"/>
			 						</TD>
			 						<TD>
			 							<s:if test="#tmpBean.sex==1">
			 								男
			 							</s:if>
			 							<s:else>
			 								女
			 							</s:else>
			 						</TD>
			 						<TD>
			 							<s:date name="#tmpBean.lastLoginTime" format="yyyy-mm-dd HH:MM:SS" />
			 						</TD>
			 						<TD>
			 							<s:property value="#tmpBean.lastLoginIP"/>
			 						</TD>
			 						<TD>
			 							<s:if test="#tmpBean.isAdmin==1">
			 								管理员
			 							</s:if>
			 							<s:else>
			 								普通用户
			 							</s:else>
			 						</TD>
			 						<TD>
										<a href="javascript:void(0);return false;" onclick="deleteBean(<s:property value='#tmpBean.id'/>)">
											删除
										</a>
			 						</TD>
			 					</TR>
			 					</s:iterator>
			 				</TABLE>
			 			</TD>
			 		</TR>
			 		<%-- 数据结束--%>
			 	</TABLE>
		 	</div>
		 	<%@include file="/manage/pageBar.jsp"%>
		 	<div>
		 		<s:hidden name="queryBean.pageNow" id="pageNow"/>
		 		<s:hidden name="queryBean.pageSize" />
		 	</div>
		 </s:form>
<iframe id="waitIframe" frameborder="0" style="width:100%;top:0; left:0;background:#cccccc;border:none; position:absolute; z-index:2; display:none" ></iframe>	
    <div id="apdiv" style="z-index:3;position:absolute; display:none;background:#FFFFFF; border: 1px solid #000000;height: 200px;width: 300px;text-align: center">
		<br/>
		<br/>
		<br/>
		<br/>
		<br/>
		<br/>
		<br/>
		<div>正在执行，请稍等。。。</div>
   	    </div>
   	    		 
 <script type="text/javascript">
 	//查询
 	function search(){
 	 	$("#pageNow").val(1);
 	 	var form =  $(document.forms[0]);
 	 	form.attr("action","<%=path%>/user/user_searchList");
 	 	form.submit();
 	}
 	//打开修改页
 	function toEdit(id){
 	 	var url = "<%=path%>";
 	 	url +="/user/user_toEdit?userBean.id=" + id + "&tmp=" + Math.round(Math.random()*1000);
 		 var flag = window.showModalDialog(url,window, "dialogHeight:600px;dialogWidth:800px;center:yes;resizable:no;status:no;scroll:yes;help:no"); 
		if(flag==1){
			search();
		}
	}
	function deleteBean(id){
	   if(confirm("确认要删除吗？")){
		   showCustomDiv(true,'apdiv','waitIframe',1);
			var url = "<%=path%>";
			url += "/user/user_deleteUserBean?userBean.id=" + id + "&tmp=" + Math.round(Math.random()*1000);
			$.get(url,function(data){
				if(data=='1'){
					alert("删除成功");
					search();
				}else if(data=='-1'){
					alert("后台异常");
				}
			});
	   }
	}
 </script>
	</body>
</html>
